package operation;

import data.DataBase;

public class ModifyRegister implements IOperation {
    @Override
    public void work(DataBase dataBase) {
        System.out.println("预约信息修改！");
        System.out.print("请输入您的身份证号：");
        String id = scanner.nextLine();

        int currentSize=dataBase.getContainSize();
        for (int i = 0; i < currentSize; i++) {
            if (dataBase.getData(i).getId().equals(id)) {
                System.out.println("找到预约信息，请修改：");
                System.out.print("请输入修改姓名：");
                String name = scanner.nextLine();
                System.out.print("请输入修改身份证号：");
                id = scanner.nextLine();
                System.out.print("请输入修改电话：");
                String phone = scanner.nextLine();
                System.out.print("请输入修改采样类型：(单采/混采)：");
                String type = scanner.nextLine();
                dataBase.getData(i).setName(name);
                dataBase.getData(i).setId(id);
                dataBase.getData(i).setPhone(phone);
                dataBase.getData(i).setType(type);
                System.out.println("修改信息成功！");
                return;
            }
        }
        System.out.println("不存在预约信息，请先预约！");

    }
}
